package com.sc.pattern.gate;

/**
 * Created  on 2018/1/6.
 *
 * @author sc
 */
public class Gate {
    private int counter = 0;
    private String name="Nobody";
    private String address="NoWhere";

    public synchronized void pass(String name,String address){
         this.address = address;
         this.name = name;
         this.counter++;
         verify();
    }
    public void verify(){
        if(this.name.charAt(0)!=this.address.charAt(0)){
            System.out.println("******BROKEN"+detail());
        }
    }
    public  String detail(){
        return "No."+counter+":"+name+","+address;
    }
}
